package org.jsets.fastboot.flowable.service.impl;

import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jsets.fastboot.flowable.model.entity.CompositeElement;
import org.jsets.fastboot.flowable.service.ICompositeElementService;
import org.jsets.fastboot.persistent.support.LambdaQuerier;
import org.jsets.fastboot.persistent.support.LambdaUpdater;
import java.util.List;
import org.jsets.fastboot.flowable.mapper.CompositeElementMapper;

/**
 * <p>流程管理--业务绑定</p>
 * 
 * @author wangjie
 *
 */
@Service
public class CompositeElementService extends ServiceImpl<CompositeElementMapper, CompositeElement> implements ICompositeElementService{

	@Override
	public void deleteByModel(String modelId) {
		new LambdaUpdater<CompositeElement>()
			.setBaseMapper(this.getBaseMapper())
			.eq(CompositeElement::getModelId, modelId)
			.delete();
	}

	@Override
	public CompositeElement getByModelId(String modelId, String taskDefKey) {
		return new LambdaQuerier<CompositeElement>()
			.setBaseMapper(this.getBaseMapper())
			.eq(CompositeElement::getModelId, modelId)
			.eq(CompositeElement::getTaskDefKey, taskDefKey)
			.selectOne();
	}

	@Override
	public CompositeElement getByDeploymentId(String deploymentId, String taskDefKey) {
		return new LambdaQuerier<CompositeElement>()
				.setBaseMapper(this.getBaseMapper())
				.eq(CompositeElement::getDeploymentId, deploymentId)
				.eq(CompositeElement::getTaskDefKey, taskDefKey)
				.selectOne();
	}

	@Override
	public List<CompositeElement> selectByModel(String modelId) {
		return new LambdaQuerier<CompositeElement>()
				.setBaseMapper(this.getBaseMapper())
				.eq(CompositeElement::getModelId, modelId)
				.selectList();
	}
	
}
